package fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.example.imagesharing.AttActivity;
import com.example.imagesharing.CollActivity;
import com.example.imagesharing.ContactActivity;
import com.example.imagesharing.IssueActivity;
import com.example.imagesharing.R;
import com.example.imagesharing.VersionActivity;
import com.example.imagesharing.ZanActivity;
import com.example.imagesharing.addActivity;
import com.google.android.material.tabs.TabLayout;
import butterknife.OnClick;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link MyFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class MyFragment extends Fragment {


    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    String TAG="MyFragment";
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    private View my;

    private RelativeLayout version;
    private RelativeLayout issue;
    private RelativeLayout contact;
    private LinearLayout zan;
    private LinearLayout coll;
    private LinearLayout att;
    private Context mContext = null;

    //    private LinearLayout version;
//    private LinearLayout version;
    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public MyFragment() {
        // Required empty public constructor
    }


    // TODO: Rename and change types and number of parameters
    public static MyFragment newInstance() {
        MyFragment fragment = new MyFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        mContext =getActivity();



        Log.i(TAG, "onCreateView: 执行到这里了哦");
        my = inflater.inflate(R.layout.fragment_my, container, false);

        contact =  my.findViewById(R.id.contact);
        version =  my.findViewById(R.id.version);
        issue =  my.findViewById(R.id.issue);
        att = my.findViewById(R.id.att);
        coll = my.findViewById(R.id.coll);
        zan = my.findViewById(R.id.zan);

        //关注
        att.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), AttActivity.class);
                startActivity(intent);
            }
        });
        //收藏
        coll.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), CollActivity.class);
                startActivity(intent);
            }
        });
        //点赞
        zan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(), ZanActivity.class);
                startActivity(intent);
            }
        });
        //常见问题
        issue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i(TAG, "onClick: 常见问题");
                Intent intent = new Intent(getActivity(), IssueActivity.class);
                startActivity(intent);
            }
        });
        //版本
        version.setOnClickListener(new  View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), VersionActivity.class);
                Log.i(TAG, "onClick: 版本");
                startActivity(intent);
            }
        });
        //联系我们
        contact.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i(TAG, "onClick: 联系我们");
                Intent intent = new Intent(getActivity(), ContactActivity.class);
                startActivity(intent);
            }
        });

        return my;
    }
}